import {
  AppIdParam,
  AppItem,
  CreateScenePageParam,
  DeleteScenePageParam,
  EditScenePageParam,
  SceneDetailItem,
  ScenePageParam,
  SceneResultModel,
  TenantCodeParam,
  TenantItem,
  ViewScenePageParam,
} from './model/sceneModel';
import { maintenanceHttp } from '/@/utils/http/axios';

enum Api {
  GET_SCENE_LIST = '/v1/maintenance/bizScenario/getList',
  CREATE_SCENE = '/v1/maintenance/bizScenario/create',
  EDIT_SCENE = '/v1/maintenance/bizScenario/edit',
  VIEW_SCENE = '/v1/maintenance/bizScenario/detail',
  DELETE_SCENE = '/v1/maintenance/bizScenario/delete',
  GET_APP_LIST = '/v1/maintenance/bizScenario/appList',
  GET_TENANT_LIST = '/v1/maintenance/bizScenario/tenantList',
  GET_TENANT_BY_APP_ID = '/v1/maintenance/bizScenario/tenantByAppId',
  GET_APP_BY_TENANT_CODE = '/v1/maintenance/bizScenario/appByTenantCode',
  GET_SCENARIO_LIST = '/v1/maintenance/bizScenario/scenarioList',
}

export const getSceneList = (params: ScenePageParam) => {
  // 获取业务列表
  const info = maintenanceHttp.get<SceneResultModel>({
    url: Api.GET_SCENE_LIST,
    params,
  });
  return info;
};

export const getAppList = () => {
  return maintenanceHttp.get<AppItem[]>({ url: Api.GET_APP_LIST });
};

export const getTenantList = () => {
  return maintenanceHttp.get<TenantItem[]>({ url: Api.GET_TENANT_LIST });
};

export const getTenantByAppId = (params: AppIdParam) => {
  return maintenanceHttp.get<TenantItem[]>({
    url: Api.GET_TENANT_BY_APP_ID,
    params,
  });
};

export const getAppByTenantCode = (params: TenantCodeParam) => {
  return maintenanceHttp.get<AppItem[]>({
    url: Api.GET_APP_BY_TENANT_CODE,
    params,
  });
};

export const createScene = (params: CreateScenePageParam) => {
  // 创建业务场景
  return maintenanceHttp.post<string>({ url: Api.CREATE_SCENE, params });
};

export const editScene = (params: EditScenePageParam) => {
  // 编辑业务场景
  return maintenanceHttp.put<string>({ url: Api.EDIT_SCENE, params });
};

export const viewScene = (params: ViewScenePageParam) => {
  // 查看业务场景
  return maintenanceHttp.get<SceneDetailItem>({ url: Api.VIEW_SCENE, params });
};

export const deleteScene = (params: DeleteScenePageParam) => {
  // 删除业务场景
  return maintenanceHttp.get<string>({ url: Api.DELETE_SCENE, params });
};
